<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="./clientTemplate.xhtml"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:c="http://java.sun.com/jsp/jstl/core">

    <ui:define name="head">
        <title>Cart</title>
    </ui:define>


    <ui:define name="content">
        <f:view>
            <h:form>
                <table border="1">
                    <caption>Product</caption>

                    <thead>
                        <tr>
                            <th>No</th>
                            <th>Product name</th>
                            <th>Quantity</th>
                            <th>Price</th>
                            <th>Calc</th>
                            <th>Action</th>
                        </tr>
                    </thead>

                    <tbody>
                        <c:forEach items="${cartBean.cart}" var="cart" varStatus="count">
                            <tr>
                                <td>${count.index + 1}</td>
                                <td>${cart.key} - Name</td>
                                <td>${cart.value}</td>
                                <td>Price</td>
                                <td>Calc</td>
                                <td><a href="#">Delete</a></td>
                            </tr>
                        </c:forEach>
                    </tbody>

                    <tfoot>
                        <tr>
                            <td></td>
                            <td colspan="3">
                                <h:commandLink action="#{cartBean.editCart(newCart)}" value="Update"/>
                                <h:commandButton action="#{cartBean.editCart(newCart)}" value="Update" />
                                <h:commandButton action="#{cartBean.resetCart()}" value="Reset" />
                            </td>
                            <td>Total</td>
                            <td><h:commandButton action="#{cartBean.removeCart()}" value="Remove cart" /></td>
                        </tr>
                    </tfoot>
                </table>
            </h:form>
        </f:view>
    </ui:define>
</ui:composition>
